package com.richman.controller;

import java.util.Iterator;
import java.util.Vector;

import com.richman.ps38.entity.SendData;

public class BetThread  extends Thread {
	
	public static Vector<String> betVec = new Vector<String>(); 
	public BetThread() {
		
	}
	
	public void removeBetVec(String target) {
		Iterator<String> iterator = betVec.iterator();
        while (iterator.hasNext()) {
            String str = iterator.next();
            if (str.equals(target)) {
                iterator.remove();
            }
        }
	}
	
	
	@Override
    public void run() {
		try {
			
			while(DecreaseRatioClient.betCtrMng!=null&&DecreaseRatioClient.bStartEngine==true) {
				try {
					Vector<SendData> sendDatas = DecreaseRatioClient.betCtrMng.getSendData();
					if(sendDatas!=null) {
						for(int i = 0;  i< sendDatas.size(); i++) {
			        		SendData tmp = sendDatas.elementAt(i);
			        		
		        			String leaguename = tmp.isnps38event.leagueName;
		        			String teams = tmp.isnps38event.homeTeam + "-vs-" + tmp.isnps38event.awayTeam;
		        			String time = tmp.isnps38event.eventTime;
		        			String pankouHalf = tmp.isnps38event.halfDXPPankou;
		        			String pankouWhole = tmp.isnps38event.wholeDXPPankou;
		        			String score = tmp.isnps38event.homeTeamScore + ":" + tmp.isnps38event.awayTeamScore;
		        			
		        			String betstrHalf = leaguename + teams + time + pankouHalf + score;		        			
		        			String betstrWhole = leaguename + teams + time + pankouWhole + score;
			    			
			    			
			    			if(betVec.contains(betstrWhole+ "全场")) {
			    				DecreaseRatioClient.betCtrMng.autobetCtrMng.dobetgame("全场大小", "2", tmp);
			    			}
			    			if(betVec.contains(betstrHalf+ "半场")) {
			    				DecreaseRatioClient.betCtrMng.autobetCtrMng.dobetgame("半场大小", "2", tmp);
			    			}					
						}
					}
					Thread.sleep(2000);
				}catch(Exception e) {
					e.printStackTrace();
				}
			}

		}catch(Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("结束run");
	}
}